package com.listeningframework.boot.autoconfigure.orm.mybatis.support;

import com.listeningframework.boot.domains.Pagination;
import com.listeningframework.boot.domains.Paging;
import com.listeningframework.boot.exception.BusinessException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.Serializable;
import java.util.List;

/**
 * 
 * Service 基类
 * 
 * @author Listening
 * @version $Id: BaseService.java, v 0.1 2014年7月23日 下午9:20:24 Listening Exp $
 */
public abstract class ListeningMybatisService<T, ID extends Serializable> {
    /**
     * 日志
     */
    protected static final Logger LOG = LoggerFactory.getLogger(ListeningMybatisService.class);

    /**
     * 分页列表查询
     *
     * @param domain 参数对象
     * @param page 分页信息
     * @return Pagination
     * @throws BusinessException 操作异常
     */
    public abstract Pagination<T> page(T domain, Paging page) throws BusinessException;

    /**
     * 插入数据
     *
     * @param domain 保存对象
     * @return Integer
     * @throws BusinessException 操作异常
     */
    public abstract Integer save(T domain) throws BusinessException;

    /**
     * 刪除数据
     *
     * @param id 主键
     * @return Integer
     * @throws BusinessException 操作异常
     */
    public abstract Integer delete(ID id) throws BusinessException;

    /**
     * 主键查询
     *
     * @param id 主键
     * @return T
     * @throws BusinessException 操作异常
     */
    public abstract T select(ID id) throws BusinessException;

    /**
     * 数据过滤
     *
     * @param domain 查询参数
     * @return List
     * @throws BusinessException 操作异常
     */
    public abstract List<T> filter(T domain) throws BusinessException;
}
